package org.blog.controller;

import org.blog.helper.Constants;
import org.blog.helper.Result;
import org.blog.model.ModelPassport;
import org.blog.service.PassportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/passport")
public class PassportController {
	
	@Autowired
	private PassportService passportService;
	
	@RequestMapping("/login")
	public String login(){
		return "";
	}
	
	
	/**
	 * 登陆
	 * @param map
	 * @param t
	 * @return
	 */
	@RequestMapping(value="/login", method = RequestMethod.GET, headers = Constants.AJAX_EL)
	@ResponseBody
	public Result<?> login(ModelPassport t){
		return passportService.auth(t);
	}
	/**
	 * 注册
	 * @param t
	 * @return
	 */
	@RequestMapping(value = "/item", method = RequestMethod.POST, headers = Constants.AJAX_EL)
	@ResponseBody
	public Result<?> register(ModelPassport t){
		return passportService.addUser(t);
	}
}
